package com.scommunity.uniapp.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.scommunity.common.ResponseResult;
import com.scommunity.domain.Help;
import com.scommunity.domain.HelpItem;
import com.scommunity.service.IHelpItemService;
import com.scommunity.service.IHelpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/help")
public class UHelpController {

    @Autowired
    private IHelpService helpService;

    @Autowired
    private IHelpItemService helpItemService;

    @GetMapping("/getbyhelptype")
    public ResponseResult getByHelpType(String helpType){
        Help help = helpService.getOne(new QueryWrapper<Help>().eq("help_type", helpType));
        List<HelpItem> helpItemList = helpItemService.list(new QueryWrapper<HelpItem>().eq("help_id", help.getHelpId()));
        return ResponseResult.success(helpItemList);
    }
}
